// PackageGatewayMapper.java
package com.example.gymlearning.mapper;

import com.example.gymlearning.entity.PackageGatewaySession;
import org.apache.ibatis.annotations.*;

@Mapper
public interface PackageGatewayMapper {

    @Select("SELECT * FROM package_gateway_session WHERE id = #{id}")
    PackageGatewaySession findSessionById(@Param("id") Long id);

    @Insert("INSERT INTO package_gateway_session (user_id, package_id, status, score, total_questions, correct_answers, " +
            "start_time, end_time, duration, question_ids, created_time) " +
            "VALUES (#{userId}, #{packageId}, #{status}, #{score}, #{totalQuestions}, #{correctAnswers}, " +
            "#{startTime}, #{endTime}, #{duration}, #{questionIds}, #{createdTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertSession(PackageGatewaySession session);

    @Update("UPDATE package_gateway_session SET status = #{status}, score = #{score}, correct_answers = #{correctAnswers}, " +
            "end_time = #{endTime}, duration = #{duration} WHERE id = #{id}")
    void updateSession(PackageGatewaySession session);
}